home *** CD-ROM | disk | FTP | other *** search
- Path: news.worldlinx.com!stupy
- From: stupy@freenet.durham.org (Steve Tupy)
- Newsgroups: comp.lang.c++
- Subject: Re: Function template problem
- Date: 5 Jan 1996 06:24:28 GMT
- Organization: Durham Free-Net
- Message-ID: <4cig6s$ii5@news.worldlinx.com>
- References: <1996Jan1.121642.44508@ac.dal.ca>
- NNTP-Posting-Host: freenet.durham.org
- X-Newsreader: TIN [version 1.2 PL2]
-
- Adrian Ross Cook (cook@is.dal.ca) wrote:
- : Hi there. Is it legal to use a template function as a member function of
- : a non-template class? If so, what is the proper syntax for doing this?
-
- : Currently I have something like the following:
-
- : class Blah{
- : ...other functions...
- : template <class Type>
- : Type foo(int index, Type aVal);
- : };
-
- the template does not need to be here as this is the prototype.
-
- : and in my definitions file:
-
- : template <class Type>
- : Type Blah::foo(int index, Type aVal)
- : {
- : ...code...
- : }
- This part looks ok. Not sure if this will work, though, what problem
- do you have with templating the whole class?
-
- : Anyway, my compiler (Turbo C++ for Windows 3.1) won't accept this. It
- : seems to be confusing my function template with a class template.
- : However, none of the C++ books I have say that you can't use a template
- : function as a class member function.
-
- Watch this, Turbo C is not well equipped to handle templates,
- certainly not as equipped as Borland flavored compilers.
-
-
- --
- Steve
-